package zjh_20230404;

public class Demo04 {
    public static void main(String[] args) {

        //main线程执行到第五的时候，线程A抢占执行，A执行完，main再执行（join（））
        for (int i = 0; i < 10; i++) {
            if (i == 5){
                MyThread thread = new MyThread("线程A");

                try {
                    thread.start();
                    thread.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName() + "执行第" + i + "次");
        }
    }
}
